Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to return a span element without a code wrap #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

resaldiv
Copy link

@resaldiv resaldiv commented Oct 20, 2020

Currently, it seems that React can't handle the memory pressure when a large output of text is being rendered. This PR is part of the solution for this issue and adds a new prop that indicates whether Ansi should return a span element without a code wrap.

@twavv
Copy link

twavv commented Oct 21, 2020

Is there a reason to support this (eg, what's the use case)? Semantically, code is almost always the correct choice.

Also, the pattern I've seen for this stuff out "in the wild" is using an as prop (Reach UI is the example that comes to mind). So instead of <Ansi spanify /> you'd use <Ansi as="span" />.

@resaldiv
Copy link
Author

Yes, I just opened this issue that explains in a better way the reason to support this and updated the description of this PR.

Thanks for the suggestion! I'm going to change the prop, to follow the pattern you mentioned.

ansiToJSON(children ?? "", useClasses ?? false).map(
elementType,
elementProps,
ansiToJSON(children ?? "", useClasses ?? false, anser ?? new Anser()).map(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big no-no in React because it means that your renders are no longer pure (the component ends up mutating the internal state of the Anser instance).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants